package com.demo.parsers;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.demo.engine.entity.BackData;
import com.demo.model.AIDAXiuModel;

public class AIDAXiuParser extends BaseParser{

	private static final String TAG = "AIDAXiuParser";
	@Override
	public void Parse(String json, BackData backData) {
		ArrayList<AIDAXiuModel> xiuItems = (ArrayList<AIDAXiuModel>) backData.getResultData();
		if (!("".equals(json)) && json != null && xiuItems != null) {
			try {
				Log.i(TAG,"json-->" +  json);
				JSONObject jobj = new JSONObject(json);
				if (jobj.has("data")) {
					JSONArray jArray = jobj.getJSONArray("data");
					for (int i = 0; i < jArray.length(); i++) {
						JSONObject data =  (JSONObject) jArray.get(i);
						AIDAXiuModel aidaxiu = new AIDAXiuModel(data.getString("uid"),data.getString("uname"),data.getString("cover"));
						xiuItems.add(aidaxiu);
					}
				}
			} catch (JSONException e) {
				e.printStackTrace();
				backData.setSuccess(false);
				backData.setMsg("parse data error!");
			}
		}
		if (getNextParser() != null) {
			getNextParser().Parse(json, backData);
		}
	}

}
